apiready= function(){
seajs.use(['../../V',"../../api","../../jquery","../../app","../../service","../../swiper"],function(V,$api,$,app,service,Swiper){
	var vm = {
		el: '.container',
	  	data: {
        shopInfo: {},
        showList: [],
				page: 1,
				classfiyId: '',
				hasMoreData: true,
				userInfo: '', // 获取用户身份
				bs: ""	//ajax弹出服务器提示控制变量
	  	},
			created: function(){
				var that = this;
				if ($api.getStorage("user")) {
						this.userInfo = $api.getStorage("user").data;
						this.bs = 1;
				}
        that.classfiyId = api.pageParam.classfiyId;
        var classfiyName = api.pageParam.classfiyName;

        $('.title').text(classfiyName); // 设置标题
        this.shopInfo = api.pageParam.shopInfo;

        this.getList();

				// 触底
				api.addEventListener({
						name: 'scrolltobottom',
						extra:{
								threshold:0
						}
				}, function(ret, err){
						that.scrolltobottom();
				});
	  	},
	  	methods:{
        getList: function (id) {
          var that = this;
					app.ajax(
						service['getGoodsList'],
						{
							data: {
								values: {
									unionid: that.shopInfo.unionid,
									shop_code: that.shopInfo.shop_code,
									page: that.page,
                  category_id: that.classfiyId
								}
							}
						},
						function (res) {
							if (res.code == 0) {
								if (res.data.length > 0) {
									for (var i = 0,len = res.data.length; i < len; i++) {
										that.showList.push(res.data[i]);
									}
									that.hasMoreData = true;
								} else {
									that.hasMoreData = false;
									api.toast({
									    msg: '没有更多数据了',
									    duration: 2000,
									    location: 'bottom'
									});

								}
							} else {
								api.toast({
										msg: res.message,
										duration: 2000,
										location: 'bottom'
								});
							}
						}
					);
        },
				// 商品详情
				toGoodsDetail: function (goods_id, group, is_yzc) {
					var that = this;
					if (is_yzc) {
						app.openWin('buyGoodsYzc', {goodsId: goods_id});
					} else {
						if (group) {
							app.openWin('groupBuyDetail',{goodsId :goods_id});
						} else {
							app.openWin('buyGoods', {goodsId: goods_id});
						}
					}
				},

				// 加载更多
				scrolltobottom: function () {
					if (this.hasMoreData) {
						this.page += 1;
					}
					this.getList();
				}
	  	},
	  	mounted:function() {

	  	}
	};
	var even = function() {}
	var newVue = new Vue(vm);
	even();
});
}
